<div id="content">

    <div id="content-header">

        <div id="breadcrumb"><a href="<?php echo site_url('Login/login') ?>" title="Go to Home" class="tip-bottom"><i
                class="icon-home"></i> 主页</a> <a href="#" class="current">用户管理</a><a href="#" class="current">代理用户列表</a>
        </div>
        <h1>代理用户列表</h1>

    </div>

    <div class="container-fluid">

        <hr>

        <div class="row-fluid">

            <div class="span12">
                <div class="widget-box">
                    <div class="widget-title"><span class="icon"><i class="icon-th"></i></span>
                        <h5>Data table</h5>
                    </div>
                    <div class="widget-content nopadding">

                        <table class="table table-bordered data-table">
                            <thead>
                            <tr>
                                <th>编号</th>
                                <th>名字</th>
                                <th>手机号</th>
                                <th>邀请码</th>
                                <th>房卡数量</th>
                                <th>代理等级</th>
                                <th>注册时间</th>
                                <th style="padding: 0px">
                                            <select onchange="doSelectt()" id='suggest_ul' style="margin:0px;padding-left:32%;border: none;line-height:20px;background-color: #efefef;width: 100%;color: #666666;font-size: 10px;font-weight:bold;">
                                                <option value="">账号状态</option>
                                                <option value="0">正常 </option>
                                                <option value="1">异常 </option>
                                            </select>
                                </th>
                                <th>操作</th>

                            </tr>
                            </thead>
                            <tbody>
                            <?php
                            $rows=$data[0];
                            foreach($rows as $value):
                            ?>
                            <tr class="gradeX">
                                <td><?php  echo $value['id']?></td>
                                <td><?php  echo $value['nickname']?></td>
                                <td><?php  echo $value['phone']?></td>
                                <td class="center"><?php  echo $value['invitecode']?></td>
                                <td class="center"><?php  echo $value['cardcount']?></td>
                                <td class="center"><?php  echo $value['lid']?></td>
                                <td class="center"><?php  echo  date('Y-m-d H:i:s',$value['regtime'])?></td>
                                <!--<td class="label label-important center" style="width: 82%"><?php  echo $value['invalid']?></td>-->
                                <?php
                         if($value['invalid']):
                                ?>
                                <td class="center" bgcolor="#f74d4d"><?php  echo '不可用'?></td>
                                <?php else:?>
                                <td class="center"><?php  echo '正常'?></td>
                                <?php    endif; ?>
                                <td>
                                    <?php
                       $id=intval($value['id']);
                       $name=$value['nickname'];
                       $url=site_url("user/editAgent/$id/$name");
                       $durl=site_url("user/doDelAgent/$id/del");
                       $rurl=site_url("user/doDelAgent/$id/re");
?>
                                    <button class="btn btn-warning btn-mini"
                                            onClick="window.open('<?php echo $url;?>','_self')">修改
                                    </button>
                                    <div id="<?php echo 'myAlert'.$id ?>" class="modal fade" aria-hidden="true">
                                        <div class="modal-header">
                                            <h3>温馨提示</h3>
                                        </div>
                                        <div class="modal-body">
                                            <div class="alert alert-block">
                                                <h4 class="alert-heading">警告!</h4>
                                                您试图删除一条数据，删除后无法恢复。请谨慎操作！
                                            </div>
                                        </div>
                                        <div class="modal-footer">
                                            <a class="btn btn-primary"
                                               href='<?php echo $durl;?>'>确认</a>
                                            <a data-dismiss="modal" class="btn" href="#">取消</a>
                                        </div>
                                    </div>
                                    <div id="<?php echo 'myDel'.$id ?>" class="modal fade" aria-hidden="true">
                                        <div class="modal-header">
                                            <h3>温馨提示</h3>
                                        </div>
                                        <div class="modal-body">
                                            <div class="alert alert-block">
                                                <h4 class="alert-heading">警告!</h4>
                                                您试图恢复一条数据。请谨慎操作！
                                            </div>
                                        </div>
                                        <div class="modal-footer">
                                            <a class="btn btn-primary"
                                               href='<?php echo $rurl;?>'>确认</a>
                                            <a data-dismiss="modal" class="btn" href="#">取消</a>
                                        </div>
                                    </div>
                                    <a href="<?php echo '#myAlert'.$id ?>" data-toggle="modal"
                                       class="btn btn-danger btn-mini">停用</a>
                                    <a href="<?php echo '#myDel'.$id ?>" data-toggle="modal"
                                       class="btn btn-primary btn-mini">恢复</a>

                                </td>
                            </tr>

                            <?php    endforeach; ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>

        </div>

    </div>

</div>
<script>
    $(function () {
        $('#myAlert').modal({
            keyboard: true
        });
    });
    function doSelect() {
//        $('#suggest_ul').css('display','block');
      //  $('#suggest_ul>:first-child').remove()
    }

    function doSelectt() {
        var state=$('#suggest_ul').val();
        var url = window.location.origin + '/admin/index.php/user/agentlist';
        console.log(url);
        $.post(url, {'state': state},
            function (data) {
                document.write(data);
                document.close();
//            $('html').html(data)
            });
    }
</script>